package com.community.process._1010.dao.view;

import com.baomidou.mybatisplus.annotation.TableName;
import com.community.process._1010.common.base.BaseEntity;
import com.community.process._1010.common.utils.SystemAmountUtil;
import com.community.process._1010.dao.entity.ProcessOrder;
import com.community.process._1010.dao.entity.ProcessOrderItem;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 到餐加工子订单
 *
 * @author Zbs
 * @since 2024-09-05
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "到餐加工子订单View")
public class ProcessOrderView implements Serializable {
    private static final long serialVersionUID = 1L;

    @Schema(description = "子订单ID")
    private Long id;

    @Schema(description = "主订单TID")
    private Long tId;

    @Schema(description = "订单状态：	    1-待确认/待支付，	    2-已支付，	    3-已发货，	    4-超时未支付，	    5-已收货，	    6-已完结/确认收货，	    7-申请退款中，	    8-发货前退款完结，	    9-发货后退款完结，	    10-收货后退款完结，	    11-退款完结，	    12-买家关闭订单，	    13-商家关闭订单")
    private Integer orderStatus;

    @Schema(description = "买家ID")
    private Long userId;

    @Schema(description = "卖家ID")
    private Long sellerId;

    @Schema(description = "就餐时间")
    private String dinnerTime;

    @Schema(description = "店铺名称")
    private String shopName;

    @Schema(description = "店铺地址")
    private String detailedAddress;

    @Schema(description = "店铺id")
    private Long shopId;

    @Schema(description = "订单类型：1 食材单 2 成品菜订单")
    private Integer orderType;

    @Schema(description = "商品名称")
    private String itemName;

    @Schema(description = "商品图片")
    private String itemImage;

    @Schema(description = "支付金额")
    private BigDecimal payAmount;

    @Schema(description = "手机号")
    private String phone;

    @Schema(description = "联系人")
    private String contactPerson;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "地区ID")
    private Long areaId;

    @Schema(description = "地区名称")
    private String areaName;

    @Schema(description = "市ID")
    private Long cityId;

    @Schema(description = "市名称")
    private String cityName;

    @Schema(description = "省ID")
    private Long provinceId;

    @Schema(description = "省名称")
    private String provinceName;

    @Schema(description = "收货详细地址")
    private String addr;

    @Schema(description = "退款原因")
    private String refundReason;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "订单商品列表")
    private List<ProcessOrderItemView> ordersItems;

    public ProcessOrderView(ProcessOrder order) {
        this.id = order.getId();
        this.tId = order.getTId();
        this.orderStatus = order.getOrderStatus();
        this.userId = order.getUserId();
        this.sellerId = order.getSellerId();
        this.orderType = order.getOrderType();
        this.itemName = order.getItemName();
        this.itemImage = order.getItemImage();
        this.payAmount = SystemAmountUtil.pennyToYuan(order.getPayAmount());
        this.phone = order.getPhone();
        this.contactPerson = order.getContactPerson();
        this.remark = order.getRemark();
        this.areaId = order.getAreaId();
        this.areaName = order.getAreaName();
        this.cityId = order.getCityId();
        this.cityName = order.getCityName();
        this.provinceId = order.getProvinceId();
        this.provinceName = order.getProvinceName();
        this.addr = order.getAddr();
        this.refundReason = order.getRefundReason();
        this.createTime = order.getCreateTime();
    }
}
